package com.guigu.lc.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.guigu.common.mapper.DFileMapper;
import com.guigu.common.mapper.MDesignProcedureDetailsMapper;
import com.guigu.common.mapper.MDesignProcedureMapper;
import com.guigu.common.util.GetUUidUtil;
import com.guigu.common.vo.SearchVo;
import com.guigu.lc.serach.designproductSerach;
import com.guigu.lc.service.DesignService;
import com.guigu.lc.view.mdesignprocedureview;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
//制定设计单的serviceimpl
@Service
public class DesignServiceimpl implements DesignService {

    @Resource
    private DFileMapper dFileMapper;

    @Resource
    private MDesignProcedureMapper mdesignprocedureMapper;

    @Resource
    private MDesignProcedureDetailsMapper mdesignprocedureDetailsMapper;

    @Resource
    private GetUUidUtil uUidUtil;

    @Override
    public designproductSerach querydfilepageService(designproductSerach vo) {
        PageHelper.startPage(vo.getPageNum(),vo.getPageSize());
        PageInfo pageInfo=new PageInfo(this.dFileMapper.querydfilepage(vo));
        designproductSerach designproductSerach=new designproductSerach();
        designproductSerach.setRows(pageInfo.getList());
        designproductSerach.setTotal(pageInfo.getTotal());
        return designproductSerach;
    }

    @Override
    public void updateinsertdesign(mdesignprocedureview mdesignprocedureview) {
        //修改产品档案的 工序组成标志 为已设计
        this.dFileMapper.updateBydesignproceduretag(mdesignprocedureview);
        //制定设计单
        String s = this.uUidUtil.returnId("201");
        mdesignprocedureview.getMdesignProcedure().setDesignId(s);
        this.mdesignprocedureMapper.insertMDesignProcedure(mdesignprocedureview);
        //添加工序
        this.mdesignprocedureDetailsMapper.insertmdesignproceduredetails(mdesignprocedureview);

    }
}
